GalleryImg = function(node){
	var self = this;
	this.node = node;
	this.gallery = undefined;
	$(this.node).click(function() { self.onClick.call(self); });
}
GalleryImg.prototype = {
	getName: function() { return $(this.node).attr('img-name'); },
	setGallery: function(g) { this.gallery = g; },
	isActive: function() { return $(this.node).hasClass('active'); },
	setActive: function() { $(this.node).addClass('active'); },
	setDisactive: function() { $(this.node).removeClass('active'); },
	onClick: function() {
		this.gallery.setImage(this);
	}
};
Gallery = function(config) {
	var self = this;
	this.bigImg = config.bigImg;
	this.active = undefined;
	this.images = [];
	$.each(config.images, function() {
		var gi = new GalleryImg(this);
		self.images.push(gi);
		gi.setGallery(self);
		if(gi.isActive()) self.active = gi;
	});
}
Gallery.prototype = {
	setImage: function(galleryImg) {
		var name = galleryImg.getName();
		this.active.setDisactive();
		this.bigImg.attr('src', '/image/product/330/'+name+'.jpg');
		this.active = galleryImg;
		this.active.setActive();
	}	
};

$(function() {
	G = new Gallery({
		bigImg: $('#img-display'),
		images: $('.galerry-img')
	});
});